package com.crm.system.controller.sendRoyaltyManager;

import com.crm.common.model.DataResponse;
import com.crm.common.model.DhPageInfo;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.vo.sendRoyaltyManager.OrderSendRoyaltyLogVO;
import com.crm.system.service.sendRoyaltyManager.SendRoyaltyLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:chaifuyou
 * @Date: 2021/5/27 10:40
 */
@RestController
@RequestMapping("/sendRoyaltyLog")
@Slf4j
public class SendRoyaltyLogController {

    @Autowired
    private SendRoyaltyLogService sendRoyaltyLogService;

    /**
     *
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @param orderId
     * @return
     */
    @PostMapping("/selectSendRoyaltyLogList")
    public DataResponse selectSendRoyaltyLogList(@RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                  @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                  @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                  @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc)
                                                  String orderId//订单id
    ){
        try{
            DhPageInfo<OrderSendRoyaltyLogVO> customerProductVODhPageInfo = sendRoyaltyLogService.selectSendRoyaltyLogList(orderId,pageIndex,pageSize,sortName,sortOrder);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),customerProductVODhPageInfo);
        }catch(Exception e){
            log.error("sendRoyaltyLog selectSendRoyaltyLogList error:", e);
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

}
